//
//  MineTableViewCell.m
//  土巴兔
//
//  Created by 千锋 on 16/1/8.
//  Copyright (c) 2016年 IOS1503薛凯. All rights reserved.
//

#import "MineTableViewCell.h"
#import "Default.h"
#import "UIImageView+WebCache.h"
@implementation MineTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createUI];
    }
    return self;
}
- (void)createUI{
    _titleLabel=[[UILabel alloc] init];
    [self.contentView addSubview:_titleLabel];
    _imageview=[[UIImageView alloc] init];
    [self.contentView addSubview:_imageview];
    _context=[[UILabel alloc] init];
    [self.contentView addSubview:_context];
    _name=[[UILabel alloc] init];
    [self.contentView addSubview:_name];
    _time=[[UILabel alloc] init];
    [self.contentView addSubview:_time];
}
//- (void)relayoutWithModel:(MineModel*)model{
//    if ([model.type intValue]==2) {
//        //套图
//        _titleLabel.frame=CGRectMake(10, 10, 300, 20);
//        _titleLabel.text=model.title;
//        _imageview.frame=CGRectMake(10, 30, (DEVICEWIDTH-20), model.height*(DEVICEWIDTH-20)/model.width);
//        [_imageview sd_setImageWithURL:[NSURL URLWithString:model.filename]];
//        _name.text=model.name;
//        _name.frame=CGRectMake(10, 30+model.height*(DEVICEWIDTH-20)/model.width, 50, 15);
//        _time.text=[NSString stringWithFormat:@"%@以前",model.time];
//        _time.frame=CGRectMake(DEVICEWIDTH-80, 30+model.height*(DEVICEWIDTH-20)/model.width, 70, 15);
//        
//    }else if ([model.type intValue]==5&&model.width!=0){
//        //知识
//        _titleLabel.frame=CGRectMake(10, 10, 300, 20);
//        _titleLabel.text=model.title;
//        _imageview.frame=CGRectMake(10, 30, (DEVICEWIDTH-20), model.height*(DEVICEWIDTH-20)/model.width);
//        [_imageview sd_setImageWithURL:[NSURL URLWithString:model.filename]];
//        _name.text=model.name;
//        _name.frame=CGRectMake(10, 30+model.height*(DEVICEWIDTH-20)/model.width, 50, 15);
//        _time.text=[NSString stringWithFormat:@"%@以前",model.time];
//        _time.frame=CGRectMake(DEVICEWIDTH-80, 30+model.height*(DEVICEWIDTH-20)/model.width, 70, 15);
//    }else if ([model.type intValue]==3){
//        //日记
//        NSLog(@"日记");
//    }else if ([model.type intValue]==6){
//        //专题
//         NSLog(@"专题");
//        _titleLabel.frame=CGRectMake(10, 10, 300, 20);
//        _titleLabel.text=model.title;
//        _imageview.frame=CGRectMake(10, 30, (DEVICEWIDTH-20), model.height*(DEVICEWIDTH-20)/model.width);
//        [_imageview sd_setImageWithURL:[NSURL URLWithString:model.filename]];
//        _context.text=model.content;
//        _context.numberOfLines=0;
//        CGSize contextsize=[self sizeWithText:model.content maxSize:CGSizeMake(DEVICEWIDTH-20, 200) fontSize:15];
//        _context.frame=CGRectMake(10, 30+model.height*(DEVICEWIDTH-20)/model.width, contextsize.width, contextsize.height);
//        
//        _name.text=model.name;
//        _name.frame=CGRectMake(10, 30+model.height*(DEVICEWIDTH-20)/model.width+contextsize.height, 50, 15);
//        _time.text=[NSString stringWithFormat:@"%@以前",model.time];
//        _time.frame=CGRectMake(DEVICEWIDTH-80, 30+model.height*(DEVICEWIDTH-20)/model.width+contextsize.height, 70, 15);
//    }
//}
- (CGSize)sizeWithText:(NSString*)text maxSize:(CGSize)maxSize  fontSize:(CGFloat)fontsize{
//    CGSize maxSize=CGSizeMake(MAXFLOAT, MAXFLOAT);
    CGSize nameSize=[text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontsize]} context:nil].size;
    return nameSize;
}
@end
